extends StateBase


var player: Player

var charge_audio_player: AudioStreamPlayer = null


func on_enter(owner = null, params = null):
	player = owner as Player
	player.charge_timer = 0 
	
	player.destroy_current_attack_charge_particle_effect()
	
	player.attack_charge_delay_timer.stop()
	player.attack_charge_delay_timer.start()
	player.attack_charge_delay_timer.timeout.connect(start_attack_charge)
	
	player.raise_hand()
	charge_audio_player = AudioManager.play_music("sfx_laser_shooting_loop")
	
	
func start_attack_charge():
	player.charge_timer = 0
	player.create_charge_particle_effect()
	

func on_exit(owner = null):
	player.attack_charge_delay_timer.timeout.disconnect(start_attack_charge)
	player.attack_charge_delay_timer.stop()
	
	player.destroy_current_attack_charge_particle_effect()
	player.hold_hand()
	
	if charge_audio_player:
		var tween = create_tween()
		tween.tween_property(charge_audio_player, "volume_db", -40, 1.0)
		tween.tween_callback(Callable(charge_audio_player, "stop"))


func on_process(delta: float, owner = null):
	pass
	
	
func on_physics_process(delta: float, owner = null):
	player.process_move_attack_charge(delta)
	player.process_gravity(delta)
	player.process_animation_attack_charge()
	player.process_vertical_move_viewroot(delta)
	player.process_pickup()
	player.move_and_slide()
	
	player.process_attack_charge(delta)
	player.process_enter_attack_dash()
	


	
	
